package com.ydgk.jishuzhan.dao;

import com.ydgk.jishuzhan.beans.Question;
import com.ydgk.jishuzhan.beans.QuestionCollection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface QuestionMapper {
    void save(Question question);

    @Select("select * from question")
    List<Question> findAll();

    @Select("select * from question where id = #{id}")
    Question findById(Integer id);

    @Select("select * from question where userId = #{id}")
    List<Question> findQuestionsById(Integer id);

    @Select("select count(*) from collection_question where userId=#{userId} and questionId=#{questionId}")
    int findCollection(Integer userId, Integer questionId);

    @Insert("insert into collection_question (userId,questionId) values (#{userId},#{questionId})")
    void collectionAdd(Integer userId, Integer questionId);

    @Select("select count(*) from collection_question where questionId=#{id}")
    int findCollections(Integer id);

    List<QuestionCollection> getCollections(Map<String, Object> map);

    Integer queryQuestionTotal(Map<String, Object> map);

    @Delete("delete from collection_question where id =#{id}")
    void deleteQCollection(Integer id);
}
